package com.ce.po;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class NTreeItem {
	private boolean checked;
	//private NTreeItem[] items;
	private Map<String, Object> map = new HashMap<String, Object>();
	private NTreeItem parent;
	private NTree tree;
	private List<NTreeItem> items = new ArrayList<NTreeItem>();
	public NTreeItem(NTreeItem parent) {
		this.parent = parent;
		this.parent.items.add(this);
	}
	
	public NTreeItem(NTree tree) {
		this.tree = tree;
		this.tree.getList().add(this);
	}
	public NTreeItem getParentItem() {
		return parent;
	}
	public NTreeItem[] getItems() {
		return items.toArray(new NTreeItem[items.size()]);
	}

	public boolean getChecked() {
		return checked;
	}
	public void setChecked(boolean checked) {
		this.checked = checked;
	}
	public int getItemCount() {
		return items.size();
	}
	
	public void setData(Object object) { 
		map.put("_data", object);
	}
	
	public void setData(String key, Object object) { 
		map.put(key, object);
	}
	
	public Object getData() {
		return map.get("_data");
	}
	
	public Object getData(String key) {
		return map.get(key);
	}
}
